package com.kata.chapter16;

import java.util.ArrayList;
import java.util.List;

/**
 * 领导阶层
 * Created by Solidsnake on 2015/4/19.
 */
public class Branch implements ITree, IBranch {

    private List<ITree> subList = new ArrayList<ITree>();
    private ITree parent;
    private String name;
    private String position;
    private int age;

    public Branch(String name, String position, int age) {
        this.name = name;
        this.position = position;
        this.age = age;
    }

    @Override
    public ITree add(ITree element) {
        element.setParent(this);
        subList.add(element);
        return this;
    }

    @Override
    public List<ITree> getSub() {
        return subList;
    }

    @Override
    public void work() {
        System.out.println("今年已经 [" + this.age + "] 岁的 [" + this.name + "] " + this.position + "正在对他的属下指手画脚");
    }

    @Override
    public void setParent(ITree parent) {
        this.parent = parent;
    }

    @Override
    public ITree getParent() {
        return this.parent;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
